package b1.scenes.suspect
{
	import b1.net.*;
	
	import com.greensock.TweenLite;
	
	import flash.display.Sprite;
	import flash.events.*;
	import flash.ui.Mouse;

	public class CluePoint extends Sprite
	{
		private var clueMessage:ClueMessage;
		private var clueIndex:int;
		private var clueValue:int;
		//0，右下；1，左下; 2，左上；3，右上;
		private var positionType:int;
		private var clueMessageWidth:Number;
		private var clueMessageHeight:Number;
		private var clueMessageX:Number;
		private var clueMessageY:Number;
		
		public function CluePoint(clueIndex:int, clueValue:int, positionType:int = 3)
		{
			super();
			var CluePoint:Class = ResourceHelper.getInstance().getClassByName("CluePoint");
			var cluePoint:Sprite = new CluePoint();
			cluePoint.width = 20;
			cluePoint.scaleY =  cluePoint.scaleX;
			addChild(cluePoint);
			addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			clueMessage = new ClueMessage(clueIndex, clueValue);
			addChild(clueMessage);
			clueMessageWidth = clueMessage.width;
			clueMessageHeight = clueMessage.height;
			clueMessage.scaleX = 0;
			clueMessage.scaleY = 0;
			clueMessageX = clueMessage.x;
			clueMessageY = clueMessage.y;
			this.positionType = positionType;
		}
		
		private function onMouseOver(event:MouseEvent):void
		{
			Mouse.cursor = "button";
			if (positionType == 0)
			{
				TweenLite.to(clueMessage, 0.2, {scaleX:1, scaleY:1});
			}
			else if (positionType == 1)
			{
				TweenLite.to(clueMessage, 0.2, {scaleX:1, scaleY:1, x:clueMessageX - clueMessageWidth});
			}
			else if (positionType == 2)
			{
				TweenLite.to(clueMessage, 0.2, {scaleX:1, scaleY:1, x:clueMessageX - clueMessageWidth, y:clueMessageY - clueMessageHeight});
			}
			else if (positionType == 3)
			{
				TweenLite.to(clueMessage, 0.2, {scaleX:1, scaleY:1, y:clueMessageY - clueMessageHeight});
			}
		}
		
		private function onMouseOut(event:MouseEvent):void
		{
			Mouse.cursor = "auto";
			TweenLite.to(clueMessage, 0.2, {scaleX:0, scaleY:0, x:clueMessageX, y:clueMessageY});
		}
		
	}
}